// src/http/api.ts
import axios from './axios'
import axios2 from './axios2'

// 定义接口返回数据的类型
export interface ApiResponse {
  // 根据实际API返回的数据结构定义
  status: string;
  data: any;
  code: any;
}

// 调用指定的API接口
export const obtainPptTemplate = async (
  params: string
): Promise<ApiResponse> => {
  // return axios.post(`/chatBase2/api/c=1059&v=4&a=aibkzj`, {
  return axios.post(
    `/api/c=1059&v=4&a=${sessionStorage.getItem('Appid') || 'aibkzj'}`,
    params
  )
}

// eslint-disable-next-line require-await
export const getWorksJson = async (params: string): Promise<ApiResponse> => {
  // return axios.post(`/chatBase2/api/c=1059&v=4&a=aibkzj`, {
  return axios.post(
    `/api/c=1061&v=4&a=${sessionStorage.getItem('Appid') || 'aibkzj'}`,
    params
  )
}

// 新增文件上传函数
export const uploadPptFile = async (
  formData: FormData
): Promise<ApiResponse> => {
  return axios.post(
    `/api5/c=1062&v=4&a=${
      sessionStorage.getItem('Appid') || 'aibkzj'
    }`,
    formData,
    {
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    }
  )
}

export const getUploadLink = async (params: string): Promise<ApiResponse> => {
  // return axios.post(`/chatBase2/api/c=1059&v=4&a=aibkzj`, {
  return axios.post(
    `/api/c=1065&v=4&a=${sessionStorage.getItem('Appid') || 'aibkzj'}`,
    params
  )
}

// 调取接口生成pptx 
export const nodeMakeFile = async (params: string): Promise<ApiResponse> => {
  return axios.post(
    `/api/c=1068&v=4&a=${sessionStorage.getItem('Appid') || 'aibkzj'}`,
    params
  )
}

// 新增作品保存
export const preservationWorks = async (
  params: string
): Promise<ApiResponse> => {
  // return axios.post(`/chatBase2/api/c=1059&v=4&a=aibkzj`, {
  return axios.post(
    `/api/c=1058&v=4&a=${sessionStorage.getItem('Appid') || 'aibkzj'}`,
    params
  )
}
